/**   
 * Copyright © 2016 北京之洲科技有限责任公司. All rights reserved.
 * 
 * @Title: InsertFin.java 
 * @Prject: carfactory
 * @Package: com.zizo.test 
 * @Description: 
 * @author: Alexis  
 * @email heyan0227@outlook.com
 * @date: 2016年8月5日 下午4:20:51 
 * @version: V1.0   
 */
package com.zizo.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.zizo.util.ConnectionPool;

/**
 * @ClassName: InsertFin
 * @Description:
 * @author: Alexis
 * @date: 2016年8月5日 下午4:20:51
 */
public class InsertFin {
	private Connection conn = ConnectionPool.getConnection("autohome", "carvoice.tpddns.cn", "3308");

	public void getIDS() {
		String pathname = "C:\\Users\\Martin\\Documents\\running\\repfin.txt";
		try {
			File file = new File(pathname);
			FileReader fr = new FileReader(file);
			BufferedReader br = new BufferedReader(fr);
			String temp = "";
			try {
				while ((temp = br.readLine()) != null) {
					System.out.println(temp);
					insert(Integer.parseInt(temp));
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	public void insert(int i) {
		PreparedStatement ps = null;
		String sql = "INSERT INTO reply_fin(yhid) VALUES(?)";
		try {
			ps = conn.prepareStatement(sql);
			ps.setInt(1, i);
			ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		InsertFin fin = new InsertFin();
		fin.getIDS();
	}
}
